using System;
using Coderoom.ScrumPlanner.Data.Contracts;
using Coderoom.ScrumPlanner.Domain;
using Coderoom.ScrumPlanner.Resources;

namespace Coderoom.ScrumPlanner.Data
{
	public sealed class SprintService : Service<ISprintRepository>
	{
		public SprintService(ISprintRepository repository) : base(repository) {}

		public SprintCollection GetSprints(Guid projectId)
		{
			return Repository.GetSprints(projectId);
		}

		public Sprint GetSprint(Guid sprintId)
		{
			return Repository.GetSprint(sprintId);
		}

		public void CreateSprint(Sprint sprint)
		{
			if (sprint == null)
				throw new ArgumentNullException("sprint");

			if (string.IsNullOrEmpty(sprint.Title))
				throw new ArgumentException(ExceptionMessages.ArgumentException_SprintTitleIsNullOrEmpty);

			Repository.CreateSprint(sprint);
		}

		public bool DeleteSprint(Guid sprintId)
		{
			return Repository.DeleteSprint(sprintId);
		}
	}
}